import { useState } from "react"

function App() {
  // 修改基础类型
  const [count, setCount] = useState(0)
  const addCount = () => {
    // count++ 无法更新视图
    setCount(count + 1)
  }
  // 修改对象状态

  const [from, setFrom] = useState({
    age: 30,
    name: "小米"
  })
  const change = () => {
    setFrom({
      ...from,
      age: 18
    })
  }
  return (
    <>
      <button onClick={addCount}>{count}</button>
      <button onClick={change}>{from.age}</button>
    </>
  )
}

export default App
